package com.calciominoBeta.Activity.task;

import java.util.ArrayList;

import org.json.JSONException;

import android.content.Context;

import com.telpoo.frame.model.BaseModel;
import com.telpoo.frame.model.BaseTask;
import com.telpoo.frame.model.TaskParams;
import com.telpoo.frame.net.BaseNetSupportBeta;
import com.telpoo.frame.object.BaseObject;
import com.telpoo.frame.utils.JsonSupport;

public class Task extends BaseTask implements TaskType{
	Context context;

	public Task(BaseModel baseModel, int taskType, ArrayList<?> list,
			Context context) {
		super(baseModel, taskType, list, context);
		this.context=context;
	}
	
	@Override
	protected Boolean doInBackground(TaskParams... params) {
		
		switch (taskType) {
		case DETAIL:
			String id=(String) dataFromModel.get(0);
			ArrayList<BaseObject> arr = new ArrayList<BaseObject>();
			 String URL_HOME = "http://www.calciomio.fr/json-exports/single";
			StringBuilder mstring = new StringBuilder(URL_HOME).append("?post_id=")
					.append(id);
			String json = "";
			String mjson = mstring.toString();
			json = BaseNetSupportBeta.getInstance().method_GET(mjson);
			
			try {
				
					arr= JsonSupport.jsonArray2BaseOj(json);
			
			
				
				dataReturn=arr;
				return TASK_DONE;
			} catch (JSONException e) {
				e.printStackTrace();
				return TASK_FAILED;
			}
			
			
			
			
			
			

		default:
			break;
		}
		
		return TASK_FAILED;
		
		
	}

}
